package cn.springcloud.fix.auth.api.feign;

import cn.springcloud.fix.auth.api.feign.fallback.RemoteAuthServiceFallBack;
import cn.springcloud.fix.auth.api.request.CheckPermissionRequest;
import cn.springcloud.fix.auth.api.response.CheckPermissionResponse;
import cn.springcloud.fix.common.core.base.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

@FeignClient(name = "springcloud-auth", path = "/auth/v1", fallback = RemoteAuthServiceFallBack.class)
public interface RemoteAuthService {

    /**
     * 调用签权服务，判断用户是否有权限
     */
    @RequestMapping("/permission")
    R<String> hasPermission(@RequestParam("url") String url,
                            @RequestParam("method") String method,
                            @RequestHeader(HttpHeaders.AUTHORIZATION) String authentication);

    @RequestMapping("/permission2")
    R<String> hasPermission2(@RequestParam("url") String url);

    @RequestMapping("/permission4")
    R<String> hasPermission3(@RequestParam Map<String, String> param);

    @RequestMapping("/checkPermission")
    CheckPermissionResponse checkPermission(@RequestBody CheckPermissionRequest request);

}
